﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Newtonsoft;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace TuiXin
{
    class IMSG
    {
        private static string GetMt(string json)
        {
            JObject jObject = JObject.Parse(json);
            return jObject["mt"].ToString();
        }

        public static LogFile log=new LogFile();
        public static void Do(string json)
        {
            int mt = int.Parse(GetMt(json));
            switch (mt)
            {
                #region MT46
                case 46:
                    Msg.MT46 mt46 = JsonConvert.DeserializeObject(json, typeof(Msg.MT46)) as Msg.MT46;
                    INIFile iniFile = new INIFile();

                    iniFile.SetValue("ExchageKey", "key", mt46.k);
                    iniFile.SetValue("PROTOCOL", "d", mt46.d.ToString());
                    break;
                #endregion

                #region MT48
                case 48:
                    Msg.MT48 mt48 = JsonConvert.DeserializeObject(json, typeof (Msg.MT48)) as Msg.MT48;
                    log.Msg("Recieve", json);
                    break;
                #endregion
                default:
                    break;
            }
        }
    }
}
